function Person(name, age) {
    this.name = name;
    this.age = age;
}

/* sort自定义排序 */
var persons = new Array(10);
for (let i = 0; i < persons.length; i++) {
    persons[i] = new Person('p' + i, parseInt(Math.random() * 100));
}
persons.sort((a, b) => a.age - b.age).forEach((p) => console.log(p));

/* map */
var arr = ['周一', '周二', '周三', '周四', '周五']
var index = [0, 1, 2, 3, 4];
//单个参数
index.map((v) => v+1).forEach((v) => console.log(v))
//两个参数，callback函数中this指向的是第二个参数对象
index.map(function (v) { return this[v]; }, arr).forEach((p) => console.log(p));

/* filter */
index.filter((v) => v%2==0).forEach((v) => console.log(v));

/* some */
index.some((v) => v>2); //是否存在大于2的元素

/* every */
index.every((v) => v>2); //是否所有元素都大于2

/* reduce */
index.reduce((pre, cur, i) => {console.log(pre, cur, i);ret})